import Vue from "vue";
import Router from "vue-router";
import { hydrantRouterMap } from "@/assets/schedule/router.js";
// import { parameterLibrary } from "@/views/parameterLibrary/router.js";
// process（进程）其实就是存在nodejs中的一个全局变量。
// 开发环境用require
// 生产环境用import
// const _import = require('./_import_' + process.env.NODE_ENV);
// { path: '/login', component: () => import('@/views/login/index')}
// 开发环境 封装的代码 module.exports = file => require('@/views/' + file + '.vue')
// 生产环境 分装的代码 module.exports = file => () => import('@/views/' + file + '.vue')
// // ()=>import('@/views/_import('
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading

Vue.use(Router);
/* layout */
import Layout from "../views/layout/Layout";

/**
 * icon : the icon show in the sidebar
 * hidden : if `hidden:true` will not show in the sidebar
 * redirect : if `redirect:noredirect` will no redirct in the levelbar
 * noDropdown : if `noDropdown:true` will has no submenu
 * meta : { role: ['admin'] }  will control the page role
 **/

let routerMap = [
    ...hydrantRouterMap,
    // ...parameterLibrary,
];

export default new Router({
    // base: "/schedule",
    mode: "hash", //后端支持可开---  history
    scrollBehavior: () => ({
        y: 0,
    }),
    routes: routerMap,
});

// export const asyncRouterMap = [];
export const asyncRouterMap = [{
        path: "/baseManager",
        component: Layout,
        name: "基础配置管理",
        icon: "el-icon-s-tools",
        authority: "baseManager",
        children: [{
                path: "userManager",
                icon: "fa-user",
                component: () =>
                    import ("@/views/admin/user/index"),
                name: "用户管理",
                authority: "userManager",
            },
            {
                path: "menuManager",
                icon: "category",
                component: () =>
                    import ("@/views/admin/menu/index"),
                name: "菜单管理",
                authority: "menuManager",
            },
            {
                path: "groupManager",
                icon: "group_fill",
                component: () =>
                    import ("@/views/admin/group/index"),
                name: "角色权限管理",
                authority: "groupManager",
            },
            {
                path: "groupTypeManager",
                icon: "fa-users",
                ////component: _import('admin/groupType/index'),
                component: () =>
                    import ("@/views/admin/groupType/index"),
                name: "角色类型管理",
                authority: "groupTypeManager",
            },
            {
                path: "gateLogManager",
                icon: "viewlist",
                ////component: _import('admin/gateLog/index'),
                component: () =>
                    import ("@/views/admin/gateLog/index"),
                name: "操作日志管理",
                authority: "gateLogManager",
            },
        ],
    },
    {
        path: "/authManager",
        component: Layout,
        name: "基础配置管理",
        icon: "setting",
        authority: "authManager",
        children: [{
            path: "serviceManager",
            ////component: _import('auth/service/index'),
            component: () =>
                import ("@/views/auth/service/index"),
            name: "用户管理",
            authority: "serviceManager",
        }, ],
    },
];